package com.cie2.janji.pages;

import java.util.List;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.cie2.janji.entities.Article;
import com.cie2.janji.entities.Promise;
import com.cie2.janji.entities.PromiseCategory;
import com.cie2.janji.entities.PromiseStatistics;
import com.cie2.janji.entities.Promise.PromiseStatus;
import com.cie2.janji.services.ArticleService;
import com.cie2.janji.services.PromiseService;
import com.cie2.janji.services.PromiseStatisticsService;
import com.cie2.janji.services.PromiseStatusUIHelper;


public class Start {

	
	@Property
	private Promise promise;
	
	@Property
	private Article article;
	
	@Property
	private PromiseCategory pc;

	// index for aligning statistics category
	@Property
	private int idx;
	
	//services
	@Inject
	private PromiseService promiseService;
	
	@Inject
	private ArticleService articleService;
	
	@Inject
	private PromiseStatisticsService statisticsService;
	
	//helper
	@Inject
	private PromiseStatusUIHelper promiseUIHelper;
	
	public List getPromises() {
		return promiseService.getHeadline();
	}
	
	public List getArticles() {
		return articleService.getMinorHeadline();
	}
	
	public Article getLatestArticle() {
		return articleService.getLatestArticle();
	}

	public PromiseStatistics getSBYStatistics() {
		return statisticsService.getSBYStatistics();
	}
	
	public List getSBYPCList() {
		return statisticsService.getSBYPCList();
	}

	public PromiseStatistics getMegaStatistics() {
		return statisticsService.getMegaStatistics();
	}

	public List getMegaPCList() {
		return statisticsService.getMegaPCList();
	}
	
	public PromiseStatistics getJKStatistics() {
		return statisticsService.getJKStatistics();
	}

	public List getJKPCList() {
		return statisticsService.getJKPCList();
	}
	
	public Boolean getStatisticsBreak() {
		if ( idx%3 == 2)
			return Boolean.TRUE;
		
		return Boolean.FALSE;
	}
	
	//helper for UI method
	public String getImage(Promise promise) {
		return promiseUIHelper.getImage(promise);
	}
	
	public String getAlt(Promise promise) {
		return promiseUIHelper.getAlt(promise);
	}
}
